﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CestoDoBebe.DAO;
using CestodoBebe.Util;


public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label lblNome = (Label)this.FindControl("lblNome");
        Label lblEmail = (Label)this.FindControl("lblEmail");
        LinkButton lnkLogout = (LinkButton)this.FindControl("lnkLogout");
        LinkButton lnkAcesso = (LinkButton)this.FindControl("lnkAcesso");

        if (Session["nome"] != null && Session["nome"].ToString() != "")
        {
            lblNome.Text = "Bem vindo(a), " + "<strong>" + Session["nome"].ToString() + "</strong>";
            lblEmail.Text = "E-mail: " + "<strong>" + Session["email"].ToString() + "</strong>";

            lblNome.Visible = true;
            lblEmail.Visible = true;
            lnkLogout.Visible = true;
            //lnkAcesso.Visible = false;
        }
        else
        {
            //lnkAcesso.Visible = true;        
        }
    }


    protected void Login_Click(object sender, EventArgs e)
    {
        Response.Redirect("Login.aspx");
    }
    protected void Logout_Click(object sender, EventArgs e)
    {

        Label lblNome = (Label)this.FindControl("lblNome");
        Label lblEmail = (Label)this.FindControl("lblEmail");
        LinkButton lnkLogout = (LinkButton)this.FindControl("lnkLogout");

        Session.RemoveAll();

        Session.Clear();

        lblNome.Visible = false;
        lblEmail.Visible = false;
        lnkLogout.Visible = false;

        Response.Redirect("CadastroCategoria.aspx");
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        Usuario objUsuario = new Usuario();
        var Email = (TextBox)Page.Master.FindControl("txtLogin");
        var Senha = (TextBox)Page.Master.FindControl("txtSenha");
        string msgLogin;

        msgLogin = objUsuario.Login(Email.Text, Senha.Text, ref objUsuario);

       

    }
}
